﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tunneler.Tools {
    /// <summary>
    /// Maintains all game game objects.
    /// </summary>
    class World {
        static World instance;

        IList<IGameObject> gameObjects;

        public IList<IGameObject> GameObjects { get { return gameObjects; } }
        public Terrain Terrain { get; set; }

        private World() {
            gameObjects = new List<IGameObject>();
        }

        public static World Instance {
            get {
                if (instance == null) {
                    instance = new World();
                }
                return instance;
            }
        }

        /// <summary>
        /// Adds a new game object into the manager.
        /// </summary>
        public void RegisterGameObject(IGameObject actor) {
            gameObjects.Add(actor);
        }

        /// <summary>
        /// Removes a game object from the manager.
        /// </summary>
        public void DeleteGameObject(IGameObject actor) {
            gameObjects.Remove(actor);
        }

        /// <summary>
        /// Removes all objects from the manager.
        /// Useful when starting a new game.
        /// </summary>
        public void Clear() {
            gameObjects.Clear();
        }
    }
}
